
#include"head.h"
/* Usage:  */
bool my_cd(sendMsg msg, client_status *clients, int net_fd){
    //函数是否要用指针
    memset(msg.msg,0,sizeof(msg.msg));
    msg.mode=1;
    strcpy(msg.msg,clients->path_last);
    printf("用户命令地址信息：%s\n",clients->path_last);
    send(net_fd,&msg,sizeof(msg),MSG_NOSIGNAL);

    recvMsg ret_msg;
    recv(net_fd,&ret_msg,sizeof(ret_msg),0);
    printf("服务端发过来的指令执行结果:%s\n",ret_msg.statu);
    printf("服务端发过来的当前路径:%s\n",ret_msg.msg);
    
    if (strcmp(ret_msg.statu, "true") == 0) {
        // 更改用户端当前 cur_path 为发送过来的信息
        strncpy(clients->path, ret_msg.msg, sizeof(clients->path) - 1);
        clients->path[sizeof(clients->path) - 1] = '\0'; // 确保路径以 null 终止
    }
    if(strcmp(ret_msg.statu, "error") == 0){
        // 打印错误
        printf("Error: Failed to change directory.\n");
    }
    return 0;
}
